<?php 
    $descTurno    = array(0 => 'Matutino',1=>'Vespertino',2=>'Noturno');
    $exibeItem = (sizeof($turmaList->getResult()) > 0) ? 'block' : 'none';

?>
<div align="left" id="div_turma_interna" style="display: <?= $exibeItem; ?>">
<fieldset style="width:auto; background-color: #FFFFFF">
        <legend style="size:auto; font-weight:bold; color:#333333">Turma</legend>
        <table id="listaTurma">
            <tr style="background-color: #cccccc; color:#FFFFFF">
              <td>&nbsp;</td>  
              <td width="46"><div align="center">Turma</div></td>
              <td width="128"><div align="center">Turno</div></td>
            </tr>
                    
<?php
    foreach ($turmaList->getResult() as $value) {

       echo '<tr>
              <td><input type="radio" id="chkTurma" name="chkTurma" value="'.$value->getTurmaId().'" /></td>  
              <td width="46"><div align="center">'.$value->getTurmaCod().'</div></td>
              <td width="128"><div align="center">'.$descTurno[$value->getTurnoCod()].'</div></td>
            </tr>';
    }
 ?>
        </table>    
</fieldset> 
</div>

<script>
    
    $(document).ready(function(){
    
          $('input[type="radio"][name="chkTurma"]').click(function (){
              
              var turmaId = jQuery('input[type="radio"][name="chkTurma"]:checked').val();
            
                if(turmaId != ''){

                     $('#div_direita').css('display','block');

                } else {
                    $('#div_direita').css('display','none');
                }

            var turmaId = jQuery('input[type="radio"][name="chkTurma"]:checked').val();

            jQuery.ajax( {
                type: "POST",
                url: '?c=c_grade_horaria&m=loadGrade',
                cache: false,
                data: {turmaId:turmaId},
                beforeSend: function (){
                    $('#div_body').addClass("div_carregando");
                },
                complete:  function(){
                    $('#div_body').removeClass("div_carregando");

                },
                success: function(data){
                   
                    $('#div_lista_grade').html(data);
                }
            });
            
        });
 });
</script>